// 分页
var page = new Controller.PageControl();
page.init({
    totalCount: 100,
    conter: ".shop-pagination",
    nowPage: 1
});

// 选择订单
$(".shop-list").on("input", ".shop-select-item", function () {
    updateStatus();
});


// 订单全选

$(".shop-main-w").on("click", ".shop-select-all", function () {
    if ($(this).attr("checked") == "checked") {
        updateOrder(true)
    } else {
        updateOrder(false)
    }
    updateStatus()
});




//更改所有订单选中状态
function updateOrder(a) {
    $(".shop-select-item").each(function () {
        $(this).attr("checked", a)
    });
}


// 更新全选状态
function updateStatus() {
    $(".shop-select-all").attr("checked", "checked")
    $(".shop-select-item").each(function () {
        if ($(this).attr("checked") != "checked") {
            $(".shop-select-all").attr("checked", false);
        }
    });
}

// 搜索框获取焦点
$(".shop-search > input").on("focus", function () {
    if (this.value == "输入商品名称、订单号") { this.value = "" }
});
// 搜索框失去焦点
$(".shop-search > input").on("focusout", function () {
    if (this.value == "") { this.value = "输入商品名称、订单号" }
});

// var sd = new Controller.DateSelect({
//     content: ".shop-select",
//     event: "hover",
//     list: [{ name: "近三个月订单", value: "近三个月订单" }, { name: "今日订单", value: "今日订单" }, { name: "2017年订单", value: "2017年订单" }, { name: "2017年以前订单", value: "2017年以前订单" }]
// });


var year = new Date().getFullYear();//Current year.
new Controller.DateSelect({
    content: ".shop-select",
    event: "hover",
    callback: function (selected) {
        vm.selectedStatus(selected);
        vm.refresh();
    },
    list: [{ name: "近三个月订单", value: "0" }, { name: "今日订单", value: "1" }, { name: year + "年订单", value: "2" }, { name: year + "年以前订单", value: "3" }],
});

// 优惠提示显示切换
$(".shop-total .shop-Offer .shop-img").on("click", function () {
    $(this).find(".shop-to").toggle();
});

$(".shop-total .shop-Offer .shop-img .shop-to-top .shop-img").on("click", function () {
    $(this).find(".shop-to").css("display", "none")
});
